from selenium import webdriver
from selenium.webdriver import ActionChains
import time

#建立浏览器实例
browser = webdriver.Chrome("C:\\Users\\Administrator\\www\\chromedriver.exe")

#打开网址
browser.get('http://localhost:8080/login')

time.sleep(3)
# username  password  的获取
username = browser.find_element_by_xpath('//*[@id="app"]/div/section/div/form/table/tr[1]/td/input')
password = browser.find_element_by_xpath('//*[@id="app"]/div/section/div/form/table/tr[2]/td/input')
button = browser.find_element_by_xpath('//*[@id="app"]/div/section/div/form/table/tr[3]/td/div/div[3]')
sub = browser.find_element_by_xpath('//*[@id="app"]/div/section/div/form/table/tr[4]/td/button[1]')
# 输入正确账号
username.send_keys('123')
password.send_keys('123')

# 拖拽验证码
# 实例化对象
action = ActionChains(browser)
action.click_and_hold(button).perform()
# 释放动作
action.reset_actions()
# 拖动距离
action.move_by_offset(215,0).perform()


sub.click()
#关闭浏览器
time.sleep(3)
browser.close()